/*
 * (C) 2012	Sheng Yi
 * Inter functions jump
 */
#include "apue.h"
#include <setjmp.h>

static void print_jmp1();
static void print_jmp2();

jmp_buf jmpbuf;

int main()
{
	int res;
	if ((res = setjmp(jmpbuf)) == 0)
	{
		printf("directory from main.\n");
		print_jmp1();
	}
	else if (res == 1)
	{
		printf("return from print_jmp1.\n");
		print_jmp2();
	}
	else if (res == 2)
		printf("return from print_jmp2.\n");
	else 
		printf("unkown return source.\n");
	return 0;
}

static void print_jmp1()
{
	longjmp(jmpbuf, 1);
}
static void print_jmp2()
{
	longjmp(jmpbuf, 2);
}
